import torch
import sys
from gxl_ai_utils.utils import utils_file


def manifest2fbank_draw(manifest_dir, fbank_dir):
    utils_file._do_compute_fbank4icefall(
        fbank_dir=fbank_dir,
        manifests_dir=manifest_dir,
        prefix="gxldata",
        partition="train",
    )


if __name__ == '__main__':
    torch.set_num_threads(1)
    torch.set_num_interop_threads(1)
    # 此时我们假设已经分好了10个temp文件， 分别是1000小时的manifest，其中含有的文件名称为gxldata_recordings_train.jsonl
    # data_index = sys.argv[1]
    # index = sys.argv[2]   # 从1开始，到5结束。
    # manifest_dir = f"./data_input/temp/wenetspeech_{data_index}/temp_{index}"
    # fbank_dir = f"./data_input/fbank/wenetspeech_{data_index}/temp_{index}"
    # utils_file.logging_print(f"manifest_dir={manifest_dir}, fbank_dir={fbank_dir}")
    for i in range(0, 2):
        for j in range(1, 26):
            data_index = i
            index = j  # 从1开始，到25结束。
            utils_file.logging_print('data_index={}, index={}'.format(data_index, index))
            manifest_dir = f"/home/work_nfs9/xlgeng/new_workspace/gxl_ai_utils/eggs/cats_and_dogs/icefall_datahandle_task/manifest2fbank_draw/data_input/temp/wenetspeech_{data_index}/temp_{index}"
            fbank_dir = f"/home/work_nfs9/xlgeng/new_workspace/gxl_ai_utils/eggs/cats_and_dogs/icefall_datahandle_task/manifest2fbank_draw/data_input/fbank/wenetspeech_{data_index}/temp_{index}"
            utils_file.logging_print(f"manifest_dir={manifest_dir}, fbank_dir={fbank_dir}")
            manifest2fbank_draw(manifest_dir, fbank_dir)
